package com.woniuxy.carlife.mapper;

import com.woniuxy.carlife.domain.StoreInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniuxy.carlife.dto.StoreinfoDto;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import javax.xml.crypto.Data;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @ClassName: StoreInfoMapper
 *@Description: 门店详情dao层
 * @author: yanzhongliang     
 * @date: 2021-04-05
 */

public interface StoreInfoMapper extends BaseMapper<StoreInfo> {
    /**
     * 功能描述〈根据门店ID修改门店收藏量〉
     * @author: yanzhongliang
     * @param:
     * @return: message
     * @Date 2021/4/10 11:26
     * @throws
     */

    @Update("UPDATE t_store_info AS s " +
            "JOIN t_store AS t ON t.store_id=s.store_info_id " +
            " SET store_info_collect=#{storeInfoCollect},store_info_update_time=#{storeInfoUpdateTime} WHERE store_id=#{storeId}")
    public void updateStoreInfoCollect(Integer storeInfoCollect, Integer storeId, Date storeInfoUpdateTime);

    /**
     * 功能描述〈根据门店ID修改门店点赞量,评论数，门店评分〉
     * @author: yanzhongliang
     * @param: storeId,storeInfoLike，storeInfoCommentary,storeInfoScoring
     * @return: null
     * @Date 2021/4/10 11:20
     * @throws
     */

    @Update("UPDATE t_store_info AS s " +
            "JOIN t_store AS t ON t.store_id=s.store_info_id " +
            " SET store_info_like=#{storeInfoLike},store_info_commentary=#{storeInfoCommentary},store_info_scoring=#{storeInfoScoring},store_info_update_time=#{storeInfoUpdateTime} WHERE store_id=#{storeId}")
    public void updateStoreInfoLike(Integer storeInfoLike,Integer storeId,Integer storeInfoCommentary,BigDecimal storeInfoScoring, Date storeInfoUpdateTime);

    /**
     * 功能描述〈根据门店ID修改门店营业时间〉
     * @author: yanzhongliang
     * @param: storeId,storeInfoBusiness
     * @return: null
     * @Date 2021/4/10 11:26
     * @throws
     */

    @Update("UPDATE t_store_info AS s " +
            "JOIN t_store AS t ON t.store_id=s.store_info_id " +
            " SET store_info_business=#{storeInfoBusiness},store_info_update_time=#{storeInfoUpdateTime} WHERE store_id=#{storeId}")
    public void updateStoreInfoBusiness(String storeInfoBusiness,Integer storeId, Date storeInfoUpdateTime);

    /**
     * 功能描述〈根据门店ID修改信誉分〉
     * @author: yanzhongliang
     * @param: storeId,storeInfoCredibility
     * @return: null
     * @Date 2021/4/12 10:02
     * @throws
     */

    @Update("UPDATE t_store_info AS s " +
            "JOIN t_store AS t ON t.store_id=s.store_info_id " +
            " SET store_info_credibility=#{storeInfoCredibility},store_info_update_time=#{storeInfoUpdateTime} WHERE store_id=#{storeId}")
    public void updateStoreInfoCredibility(Integer storeId, BigDecimal storeInfoCredibility, Date storeInfoUpdateTime);

    /**
     * 功能描述〈根据门店ID修改总订单数〉
     * @author: yanzhongliang
     * @param: storeID,storeInfoOrder
     * @return: null
     * @Date 2021/4/12 10:07
     * @throws
     */

    @Update("UPDATE t_store_info AS s " +
            "JOIN t_store AS t ON t.store_id=s.store_info_id " +
            " SET store_info_order=#{storeInfoOrder},store_info_update_time=#{storeInfoUpdateTime} WHERE store_id=#{storeId}")
    public void updateStoreInfoOrder(Integer storeId,Integer storeInfoOrder, Date storeInfoUpdateTime);

    /**
     * 功能描述〈查询全部门店详情〉
     * @author: yanzhongliang
     * @param: null
     * @return: StoreinfoDto
     * @Date 2021/4/15 11:33
     * @throws
     */

    @Select("SELECT  " +
            "s.store_id, " +
            "store_name, " +
            "store_phone, " +
            "store_precision, " +
            "store_latitude, " +
            "store_image, " +
            "store_shopkeeper_name, " +
            "store_address, " +
            "store_status, " +
            "store_info_like, " +
            "store_info_collect, " +
            "store_info_business, " +
            "store_info_credibility, " +
            "store_info_commentary, " +
            "store_info_scoring, " +
            "store_info_order, " +
            "tags_name " +
            "FROM t_store AS s " +
            "JOIN t_store_info AS i " +
            "ON s.store_id=i.store_info_id " +
            "JOIN t_tags AS t  " +
            "ON s.store_id=t.tags_id;")
    public List<StoreinfoDto> getStoreInfoAndTagsListAll();
}
